package com.aistar.service.impl;

import com.aistar.mapper.ProductMapper;
import com.aistar.pojo.Product;
import com.aistar.pojo.ProductExample;
import com.aistar.service.SelectkeyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SelectkeyServiceImpl implements SelectkeyService {
    @Autowired
    private ProductMapper productMapper;
    @Override
    public List<Product> selectByKey(String keyWord) {
        String key = "%"+keyWord+"%";
        ProductExample productExample = new ProductExample();
        ProductExample.Criteria productCriteria = productExample.createCriteria();
        productCriteria.andProductNameLike(key);
        productCriteria.andProductStatusEqualTo(1);
        List<Product> productList = productMapper.selectByExample(productExample);
        return productList;
    }
}
